<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <ul>

    </ul>

    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        // const url = 'http://www.liulongbin.top:3006/api/getbooks';
        // axios.get(url);
        const url = 'http://www.liulongbin.top:3006/api/getbooks';
        // axios.get(url, {
        //     // get请求参数放在params对象中
        //     params: {
        //         id: 1,
        //     },
        // });

        // Promise
        console.log(1);
        axios({
            method: 'get',
            url,
        }).then((res) => {
            console.log(res.data.data);
            const ul = document.querySelector('ul');
            for (const item of res.data.data) {
                const li = document.createElement('li');
                li.innerText = item.bookname;
                ul.appendChild(li);
            }
        });
        console.log(2);

    </script>
</body>
</html>